﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Widgetsphere.Autos.Websitev2.Objects;
using Widgetsphere.WebUtils;

namespace Widgetsphere.Autos.Websitev2.UserControls
{
	public partial class MakeDimensionControl : DimensionDisplayControl
	{
		#region Constructors

		public MakeDimensionControl()
		{
			this.LinkSetup += new EventHandler<DimensionDisplayEventArgs>(DimensionControl_LinkSetup);
		}

		#endregion

		#region Event Handlers

		private void DimensionControl_LinkSetup(object sender, DimensionDisplayEventArgs e)
		{
			var url = new URL(this.Request.Url.AbsoluteUri);

			e.Query.Zip = url.Parameters.GetValue("zip", "");
			if (!string.IsNullOrEmpty(e.Query.Zip))
				e.Query.Radius = 50;
			e.Query.Make = e.Refinement.FieldValue;
			e.Query.DimensionValueList.Add(e.Refinement.DVIdx);
		}

		#endregion

		#region Property Implementations

		protected override PlaceHolder MorePanel
		{
			get { return pnlMore; }
		}

		protected override Table MainTable
		{
			get { return tableMain; }
		}

		#endregion

	}
}